//************************************************************************
// author	:	staylook												
// date		:	2011/4/3 1:21 					                 
//************************************************************************
#ifndef SL_CAMERA_H_
#define SL_CAMERA_H_
#include "Transform.h"
#include "Viewport.h"
#include "Matrix4.h"
#include "Vector3.h"
#include "State.h"
namespace sl
{
	class View;
	class Viewport;
	class SL_EXPORT Camera : public Transform
	{
		public:
			Camera(void);
			~Camera(void);

			void SetStates( sl::State * states ) { m_rState = states; }

			sl::State * GetStates() { return m_rState.get();}

			void SetViewport( u32 x, u32 y, u32 width, u32 height );

			void SetViewport( sl::Viewport * viewport );

			sl::Viewport* GetViewport(){ return m_rViewport.get();};

			void SetView( sl::View * pView ) { m_pView = pView; };
			sl::View * GetView() const { return m_pView; };

			void SetSceneData( sl::Node * pNode );

			sl::Node * GetSceneData();

			void SetProjectionMatrix( const sl::Matrix4 & matrix );

			void SetProjectionMatrixAsOrho( double left, double right,
											double bottom, double top,
											double zNear, double zFar );

			void SetProjectionMatrixAsOrtho2D( double left, double right, 
												double bottom, double top );

			void SetProjectionMatrixAsFrustum(	double left, double right,
												double bottom, double top,
												double zNear, double zFar );
			
			void SetProjectionMatrixAsProjective( double fov, double aspectRatio, 
												double zNear, double zfar );

			// store the postion and camera coordinates
			void SetViewMatrix( const sl::Matrix4 & matrix );

			void SetViewMatrixAsLookAt( const sl::Vector3 & eye, const  sl::Vector3 & center, const sl::Vector3 & up );
			
			const sl::Matrix4  GetViewMatrix() const { return m_mView; } 
			const sl::Matrix4  GetProjectMatrix() const { return m_mProjection; }

			sl::Matrix4							m_mProjection;
			sl::Matrix4							m_mView;

			sl::View*							m_pView;
			sl::ref_ptr< sl::Viewport >			m_rViewport;
			
			sl::ref_ptr< sl::State >		m_rState;
	};

}


#endif
